﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql;
using MySql.Data;
using MySql.Data.MySqlClient;
using MySql.Data.Entity;
using ASV.Classes;
using System.Data;
using System.Net.Mail;

namespace ASV.Benutzer
{
    public partial class Support : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            Connection mycon = new Connection();
            object[] values = null;
            string kdn;
            DataTable datatable;
            ListItem option;
            int numrows;
            int numcells;

            kdn = HttpContext.Current.Session["kundennummer"].ToString();

            datatable = mycon.select("SELECT kundennummer_btl,vVersionsID,p.Name,vv.versionsnummer  FROM `bestellung` as b JOIN lizenzverwaltung as lz on lz.lizenzID = b.lizenzID JOIN versionsverwaltung as vv on vv.vVersionsID = lz.versionsID JOIN produkte as p on p.ID = vv.ProduktID JOIN produkttyp as pt on p.prodkttype = pt.ID WHERE kundennummer_btl = '" + kdn + "';");
            
            for (int x = 0; x < datatable.Rows.Count; x++)
            {
                values = datatable.Rows[x].ItemArray;

                numrows = datatable.Rows.Count;
                numcells = datatable.Columns.Count;

                option = new ListItem();
                option.Value = values[2].ToString();
                option.Text = values[2].ToString() + " Version " + values[3].ToString();
                ProdukteOption.Items.Add(option);
            }
        }

        protected void email_send(object sender, EventArgs e)
        {
            string kdn = HttpContext.Current.Session["kundennummer"].ToString();
            string email = HttpContext.Current.Session["email"].ToString();

            sendEmail mailtoSupport = new sendEmail("Noreply@0815.de", "support@0815.de", email, "", "Support für Kunde " + kdn + " zu Produkt " + ProdukteOption.SelectedItem.Text, "Vielen Dank für ihr Feedback wir werden uns so schnell wie möglich um das Problem kümmern und ihnen antworten. Fehlerbeschreibung:" + fehlerbeschreibung.Value);
            sendEmail mailtocustomer = new sendEmail("Noreply@0815.de", email, "", "", "Support für Kunde " + kdn + " zu Produkt " + ProdukteOption.SelectedItem.Text, fehlerbeschreibung.Value);

            Response.Redirect("../Start.aspx");
        }
    }
}
